package com.jyw.business.ast.controller;

import java.util.List;
import javax.validation.Valid;

import com.jyw.business.ast.domain.dto.web.AstTransferDto;
import com.jyw.business.ast.domain.dto.web.AstTransferPageDto;
import com.jyw.business.ast.domain.dto.web.AstRejectedDto;
import com.jyw.business.ast.domain.vo.web.AstTransferAuditPageVo;
import com.jyw.business.ast.domain.vo.web.AstTransferDetailVo;
import com.jyw.business.ast.domain.vo.web.AstTransferPageVo;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.BasePage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.enums.BusinessType;
import com.jyw.business.ast.service.IAstTransferService;
import com.jyw.common.core.page.TableDataInfo;

/**
 * 资产-转移信息Controller
 * 
 * @author system
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/ast/transfer")
@Api(tags = "资产转移")
public class AstTransferController extends BaseController
{
    @Autowired
    private IAstTransferService astTransferService;

    /**
     * 查询资产-转移信息列表
     */
    @PreAuthorize("@ss.hasPermi('ast:transfer:list')")
    @PostMapping("/list")
    @ApiOperation("资产转移分页查询")
    public TableDataInfo<AstTransferPageVo> list(BasePage page, @RequestBody AstTransferPageDto astTransfer)
    {
        startPage();
        List<AstTransferPageVo> list = astTransferService.transferPage(astTransfer);
        return getDataTable(list);
    }

    /**
     * 获取资产-转移信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ast:transfer:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("转移申请详情")
    public CommonResult<AstTransferDetailVo> getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(astTransferService.transferDetail(id));
    }

    /**
     * 新增资产-转移信息
     */
    @PreAuthorize("@ss.hasPermi('ast:transfer:add')")
    @Log(title = "资产-转移信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("转移申请")
    public CommonResult add(@RequestBody AstTransferDto dto)
    {
        astTransferService.transfer(dto);
        return CommonResult.success();
    }


    /**
     * 删除资产-转移信息
     */
    @PreAuthorize("@ss.hasPermi('ast:transfer:remove')")
    @Log(title = "资产-转移信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    @ApiOperation("转移申请撤销")
    public CommonResult remove(@PathVariable Long id)
    {
        astTransferService.revoke(id);
        return CommonResult.success();
    }


    /**
     * 查询资产-转移信息列表
     */
    @PreAuthorize("@ss.hasPermi('ast:transfer:audit:list')")
    @PostMapping("/audit/list")
    @ApiOperation("资产转移-审核-分页查询")
    public TableDataInfo<AstTransferAuditPageVo> auditList(BasePage page, @RequestBody AstTransferPageDto astTransfer)
    {
        startPage();
        List<AstTransferAuditPageVo> list = astTransferService.transferAuditPage(astTransfer);
        return getDataTable(list);
    }

    /**
     * 查询资产-转移信息列表
     */
    @PreAuthorize("@ss.hasPermi('ast:transfer:audit:pass')")
    @PutMapping("/audit/pass")
    @ApiOperation("资产转移-审核-通过")
    public CommonResult auditPass(@RequestBody List<Long> list)
    {
        astTransferService.pass(list);
        return CommonResult.success();
    }

    /**
     * 查询资产-转移信息列表
     */
    @PreAuthorize("@ss.hasPermi('ast:transfer:audit:rejected')")
    @PutMapping("/audit/rejected")
    @ApiOperation("资产转移-审核-驳回")
    public CommonResult auditRejected(@RequestBody @Valid AstRejectedDto dto)
    {
        astTransferService.auditRejected(dto);
        return CommonResult.success();
    }
}
